package BackgammonBot.Algorithmus;

import java.util.ArrayList;

public class FirstTurn 
{
	public static ArrayList<int[]> getFirstTurn(int[] dice, char player)
	{
		ArrayList<int[]> move = new ArrayList<int[]>();
		int[] firstMove = new int[2];
		int[] secondMove = new int[2];
		
		if (dice[0] == 1 || dice[1] == 1)
		{
			if (dice[0] == 2 || dice[1] == 2)
			{
				firstMove[0] = player == 'b' ? 13 : 12;
				firstMove[1] = player == 'b' ? 11 : 14;
				secondMove[0] = player == 'b' ? 6 : 19;
				secondMove[1] = player == 'b' ? 5 : 20;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 3 || dice[1] == 3)
			{
				firstMove[0] = player == 'b' ? 8 : 17;
				firstMove[1] = player == 'b' ? 5 : 20;
				secondMove[0] = player == 'b' ? 6 : 19;
				secondMove[1] = player == 'b' ? 5 : 20;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 4 || dice[1] == 4)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 23 : 2;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 9 : 16;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 5 || dice[1] == 5)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 23 : 2;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 8 : 17;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 6 || dice[1] == 6)
			{
				firstMove[0] = player == 'b' ? 13 : 12;
				firstMove[1] = player == 'b' ? 7 : 18;
				secondMove[0] = player == 'b' ? 8 : 17;
				secondMove[1] = player == 'b' ? 7 : 18;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
		}
		if (dice[0] == 2 || dice[1] == 2)
		{
			if (dice[0] == 3 || dice[1] == 3)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 21 : 4;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 11 : 14;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 4 || dice[1] == 4)
			{
				firstMove[0] = player == 'b' ? 8 : 17;
				firstMove[1] = player == 'b' ? 4 : 21;
				secondMove[0] = player == 'b' ? 6 : 19;
				secondMove[1] = player == 'b' ? 4 : 21;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 5 || dice[1] == 5)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 22 : 3;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 8 : 17;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 6 || dice[1] == 6)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 18 : 7;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 11 : 14;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
		}
		if (dice[0] == 3 || dice[1] == 3)
		{
			if (dice[0] == 4 || dice[1] == 4)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 20 : 5;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 10 : 15;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 5 || dice[1] == 5)
			{
				firstMove[0] = player == 'b' ? 8 : 17;
				firstMove[1] = player == 'b' ? 3 : 22;
				secondMove[0] = player == 'b' ? 6 : 19;
				secondMove[1] = player == 'b' ? 3 : 22;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 6 || dice[1] == 6)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 18 : 7;
				secondMove[0] = player == 'b' ? 13 : 12;
				secondMove[1] = player == 'b' ? 10 : 15;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
		}
		if (dice[0] == 4 || dice[1] == 4)
		{
			if (dice[0] == 5 || dice[1] == 5)
			{
				firstMove[0] = player == 'b' ? 13 : 12;
				firstMove[1] = player == 'b' ? 9 : 16;
				secondMove[0] = player == 'b' ? 13 : 19;
				secondMove[1] = player == 'b' ? 12 : 17;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
			if (dice[0] == 6 || dice[1] == 6)
			{
				firstMove[0] = player == 'b' ? 8 : 17;
				firstMove[1] = player == 'b' ? 2 : 23;
				secondMove[0] = player == 'b' ? 6 : 19;
				secondMove[1] = player == 'b' ? 2 : 23;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
		}
		if (dice[0] == 5 || dice[1] == 5)
		{
			if (dice[0] == 6 || dice[1] == 6)
			{
				firstMove[0] = player == 'b' ? 24 : 1;
				firstMove[1] = player == 'b' ? 18 : 7;
				secondMove[0] = player == 'b' ? 18 : 7;
				secondMove[1] = player == 'b' ? 13 : 12;
				move.add(firstMove);
				move.add(secondMove);
				return move;
			}
		}
		
		return null;
	}
}
